home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / eclbip / eclbip.sty < prev    next >
Text File  |  1991-08-04  |  3KB  |  113 lines

  1. % eclbip.sty (C) Hideki ISOZAKI Nov. 24, 1990
  2. % \ignorespaces Dec.2, 1990
  3. % draw a bipartite graph with epic.sty
  4.  
  5. \typeout{ECL Bipartite graph style file by isozaki Dec.2, 1990}
  6.  
  7. \endlinechar=-1\relax
  8. \makeatletter
  9.  
  10. \newdimen\bip@len
  11. \newbox\bip@box
  12.  
  13. % #1...Width of Left Node Group
  14. % #2...Width of Gap between Left Node Group and Right Node Group
  15. % #3...Width of Right Node Group
  16. % #4...Height of Vertical Gap between Nodes
  17. % #5...Width of a Bullet and its Label
  18.  
  19. \def\bipartite#1#2#3#4#5{
  20.     \bip@init\bip@sep{#4}
  21.     \bip@init\bip@lW{#1}
  22.     \bip@init\bip@eW{#2}
  23.     \bip@init\bip@rW{#3}
  24.     \let\bip@lX=\bip@lW
  25.     \bip@init\bip@rX{\bip@lX\p@}\bip@add\bip@rX{#2}
  26.     \bip@init\bip@tX{\bip@rX\p@}\bip@add\bip@tX{#3}
  27.     \bip@init\bip@lY{\z@}
  28.     \bip@init\bip@rY{\z@}
  29.     \xdef\bip@bot{0.0}
  30.         \bip@init\bip@elX{\bip@lX\p@}
  31.         \bip@add\bip@elX{#5}
  32.         \bip@init\bip@erX{\bip@rX\p@}
  33.         \bip@add\bip@erX{-#5}
  34.     \unitlength=\p@
  35.     \def\endbipartite{\endpicture
  36.     \hbox{\vrule\@depth\bip@bot\p@\@height\z@\@width\z@}}
  37.     \picture(\bip@tX,0)(0,0)\ignorespaces}
  38.  
  39. %
  40. % \leftnode[#1]{#2}
  41. %   #1=label, #2=content
  42. %
  43. % \leftnode{#1}=\leftnode[#1]{#1}
  44. %
  45.  
  46. \def\leftnode{\@dblarg{\@leftnode}}
  47.  
  48. \def\@leftnode[#1]#2{
  49.     \setbox\bip@box=\hbox to \z@{\hss
  50.         \@iparbox[c]{\bip@lW\p@}{\raggedleft #2}}
  51.     \bip@init\bip@halfH{-.5\ht\bip@box}
  52.     \bip@add\bip@halfH{-.5\dp\bip@box}
  53.     \bip@init\bip@corrY{\bip@halfH\p@}
  54.     \bip@add\bip@corrY{\dp\bip@box}
  55.     \bip@add\bip@lY{\bip@halfH\p@}
  56.     \put(\bip@lX,\bip@lY){\raise\bip@corrY\p@\box\bip@box}
  57.     \put(\bip@elX,\bip@lY){\makebox(0,0){$\bullet$}}
  58.         \expandafter\edef\csname bip@L#1\endcsname{\bip@lY}
  59.     \bip@add\bip@lY{\bip@halfH\p@}
  60.     \bip@max\bip@bot{-\bip@lY\p@}
  61.     \bip@add\bip@lY{-\bip@sep\p@}\ignorespaces}
  62.  
  63. \def\rightnode{\@dblarg{\@rightnode}}
  64.  
  65. \def\@rightnode[#1]#2{
  66.     \setbox\bip@box=\hbox to \z@{
  67.         \@iparbox[c]{\bip@rW\p@}{\raggedright #2}\hss}
  68.     \bip@init\bip@halfH{-.5\ht\bip@box}
  69.     \bip@add\bip@halfH{-.5\dp\bip@box}
  70.     \bip@init\bip@corrY{\bip@halfH\p@}
  71.     \bip@add\bip@corrY{\dp\bip@box}
  72.     \bip@add\bip@rY{\bip@halfH\p@}
  73.     \put(\bip@rX,\bip@rY){\raise\bip@corrY\p@\box\bip@box}
  74.     \put(\bip@erX,\bip@rY){\makebox(0,0){$\bullet$}}
  75.         \expandafter\edef\csname bip@R#1\endcsname{\bip@rY}
  76.     \bip@add\bip@rY{\bip@halfH\p@}
  77.     \bip@max\bip@bot{-\bip@rY\p@}
  78.     \bip@add\bip@rY{-\bip@sep\p@}\ignorespaces}
  79.  
  80. %
  81. %   Draw Edges between Nodes
  82. %
  83.  
  84. \def\brush#1{\def\bip@brush{#1}\ignorespaces}
  85. \brush{\drawline}
  86.  
  87. \def\match#1#2{
  88.     \bip@brush(\bip@elX,\@nameuse{bip@L#1})(\bip@erX,\@nameuse{bip@R#2})
  89.     \ignorespaces}
  90.  
  91. %
  92. % (1) Avoidance of too much use of dimen.
  93. % (2) Easy conversion between picture coord and real dimen
  94. %  ---> Keep dimen without 'pt'
  95. %
  96.  
  97. \def\bip@init#1#2{\bip@len=#2\relax
  98.     \edef#1{\expandafter\@RemoveDim\the\bip@len}}
  99.  
  100. \def\bip@add#1#2{\bip@len=#1\p@\relax\advance\bip@len by #2\relax
  101.     \edef#1{\expandafter\@RemoveDim\the\bip@len}}
  102.  
  103. \def\bip@max#1#2{\bip@len=#1\p@\relax
  104.     \ifdim\bip@len<#2\relax\bip@len=#2
  105.     \xdef#1{\expandafter\@RemoveDim\the\bip@len}\fi}
  106.  
  107. {\catcode`\p=12 \catcode`\t=12
  108. \gdef\@RemoveDim#1pt{#1}}
  109.  
  110. \endlinechar=13\relax
  111.  
  112. \endinput
  113.